package QQcommon;
import QQclient.UserclientService;


public class QQ_View {
    private boolean loop=true;
    private String key;
    public UserclientService userclientService=new UserclientService();

    public static void main(String[] args) {
        new QQ_View().QQmue();
    }
    public void QQmue(){
        while (true){
            System.out.println("     1:登录QQ     ");
            System.out.println("     9:退出登录    ");
            System.out.println("请输入你的操作：    ");
            key= Utility.readString(1);
            switch (key){
                case "1":
                    System.out.println("请输入Id：     ");
                    String Id=Utility.readString(50);
                    System.out.println("请输入密码：     ");
                    String pwd=Utility.readString(50);
                    if (userclientService.checkUser(Id,pwd)){//登录是否成功
                        System.out.println("欢迎"+Id);
                        while (loop){
                            System.out.println("显示二级菜单");
                            System.out.println("\t\t1.显示用户列表");
                            System.out.println("\t\t2.群发消息");
                            System.out.println("\t\t3.私聊消息");
                            System.out.println("\t\t4.发送文件");
                            System.out.println("\t\t9.退出系统");
                            System.out.println("输入你的操作：");
                            key=Utility.readString(1);
                            switch (key){
                                case "1":
                                    userclientService.onlineFriendList();
                                    break;
                                case "2":
                                    System.out.println("请输入想要说的话：");
                                    String chats=Utility.readString(500);
                                    userclientService.Chats(chats);
                                    break;
                                case "3":
                                    System.out.println("输入你想要私聊的对象：");
                                    String grtID=Utility.readString(50);
                                    System.out.println("请输入想要说的话：");
                                    String chat=Utility.readString(500);
                                    userclientService.Chat(grtID,chat);
                                    break;
                                case "4":
                                    System.out.println("请输入你发送文件的路径：");
                                    String src=Utility.readString(100);
                                    System.out.println("请输入你要发送的对象：");
                                    String getId=Utility.readString(50);
                                    System.out.println("请输入你发送文件的路径：");
                                    String dest=Utility.readString(100);
                                    userclientService.File(getId,src,dest);

                                    break;
                                case "9":
                                    loop=false;
                                    userclientService.ExitThread();

                                    break;
                            }
                        }
                    }else {
                        System.out.println("登陆失败！");
                    }
            }
        }
    }
}
